const Ranking = resolve => require(['./components/Ranking.vue'], resolve)  //排行榜
const SongSheet = resolve => require(['./components/SongSheet.vue'], resolve) //歌单列表
const User_Info = resolve => require(['./components/User_Info.vue'], resolve) //个人中心

const searchSong = resolve => require(['./components/searchSong.vue'], resolve) //歌曲搜索 √
const Search = resolve => require(['./components/Search.vue'], resolve)         //搜索  √
const HotSearch = resolve => require(['./components/HotSearch.vue'], resolve)  //热搜 √
const SearchRes = resolve => require(['./components/SearchRes.vue'], resolve) //搜索结果 √
const SongRes = resolve => require(['./components/SongRes.vue'], resolve)  //搜索结果2 √
const Login = resolve => require(['./components/Login.vue'], resolve)   //登陆 
const Reg = resolve => require(['./components/Reg.vue'], resolve)   //注册
const NewAlbum = resolve => require(['./components/NewAlbum.vue'], resolve)   //新歌榜页面 
const newSongSheet = resolve => require(['./components/newSongSheet.vue'], resolve)   //新歌单页面 
const RankingPage = resolve => require(['./components/RankingPage.vue'], resolve)  //what排行页
const kernel = resolve => require(['./components/kernel.vue'], resolve)  //播放器内核 

export default {
    // linkActiveClass: 'mui-active',
    mode: 'hash',//切换路径模式,变成history模式
    scrollBehavior(to, from, savedPosition) {
        console.log('savedPosition0000:', savedPosition);
        if (savedPosition) {
            console.log('savedPosition:', savedPosition);
            setTimeout(() => {
                return { x: savedPosition.x, y: savedPosition.y }
                // window.scrollTo(savedPosition.x, savedPosition.y)
            }, 200)
        }
        // return {x:0,y:0}
        // window.scrollTo(0, 0)
    },
    routes: [
        // page
        { path: '/home', component: resolve => require(['./components/HomeView.vue'], resolve) },//异步组件写法
        {
            path: '/ranking',  //排行榜 
            component: Ranking,
        },
        {
            path: '/SongSheet',    //歌单列表
            component: SongSheet,
        },
        {
            path: '/user_info',     //个人中心
            component: User_Info,
        },

        // compontents
        {
            path: '/searchSong', //歌曲搜索页面
            component: searchSong,
            children: [
                { path: 'HotSearch', component: HotSearch },
                { path: 'SearchRes', component: SearchRes },
                { path: 'SongRes', component: SongRes },
            ]
        },
        {
            path: '/RankingPage', //what排行页
            name: 'RankingPage',
            component: RankingPage,
        },
        {
            path: '/kernel', //播放器内核
            component: kernel,
        },
        {
            path: '/Search', //搜索
            component: Search,
        },
        {
            path: '/NewAlbum',  //新歌榜页面 
            component: NewAlbum,
        },
        {
            path: '/newSongSheet',  //新歌单页面 
            component: newSongSheet,
        },
        {
            path: '/login',      //登陆
            component: Login,
        },
        {
            path: '/reg',      //注册
            component: Reg,
        },
        { path: '*', redirect: '/home' }, //重定向首页
    ]
}